package com.szxy;

import com.szxy.service.AccountService;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zwz
 * @Date:2020/7/15 21:04
 * @Description:com.szxy
 * @Version:1.0
 **/
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.szxy.mapper")
@RestController
public class AccountServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(AccountServiceApplication.class, args);
    }

    @Autowired
    private AccountService accountService;

    /**
     * 暴露接口
     * @return
     */
    @GetMapping("/deBin/{userId}/{money}")
    public ResponseEntity<Void> deBin(
            @PathVariable String userId,
            @PathVariable Integer money) {
        this.accountService.reduceMoney(userId, money);
        return ResponseEntity.ok().build();
    }

}
